<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    const obj = {
        init:function(){
            console.log("obj的init")
        },
        show(){
            console.log("obj的show")
        }
    }

    function Parent(m){
        this.msg = m;
    }
    Parent.prototype.show = function(){
        // console.log(this.msg)
        console.log("hello")
    }

    function Child(m){}
    // 注意深浅拷贝
    // Child.prototype = Parent.prototype;
    // for(let i in Parent.prototype){
    //     Child.prototype[i] = Parent.prototype[i];
    // }
    // for(let i in obj){
    //     Child.prototype[i] = obj[i];
    // }

    Child.prototype = { ...obj, ...Parent.prototype };

    Child.prototype.show = function(){
        console.log("world")
    }

    const p = new Parent();
    console.log(p);
    p.show();

    const c = new Child();
    console.log(c);
    c.show();
    c.init();

    
</script>
</html>